namespace MaymuseMS.DAL {
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using MaymuseMS.Models;
    using MaymuseMS.Models.ValueObject;

    public class FinishedRepository : ProductRepository<Finished> {
        public FinishedRepository(MaymuseMSContext context)
            : base(context) {

        }
        public override IEnumerable<AutoCompleteModel> Get(string term) {
            return dbSet.Where(p => p.Name.Contains(term) || p.Number.Contains(term))
                .OrderByDescending(p => p.ProductId).Take(100)
                .Select(p => new AutoCompleteModel {
                    Id = p.ProductId,
                    Name = p.Name,
                    Number = p.Number
                });
        }
    }
}
